package com.zcp.greendaodemo;

import android.app.Application;
import android.database.sqlite.SQLiteDatabase;

import com.zcp.greendaodemo.greendao.DaoMaster;
import com.zcp.greendaodemo.greendao.DaoSession;

/**
 * Created by Administrator on 2017/3/30.
 */

public class App extends Application {

    private static DaoSession session;

    @Override
    public void onCreate() {
        super.onCreate();
        setDb();
    }

    private void setDb() {
        DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(this, "zcp.db", null);
        SQLiteDatabase database = devOpenHelper.getWritableDatabase();
        DaoMaster master = new DaoMaster(database);
        session = master.newSession();
    }

    public static DaoSession getDb() {
        return session;
    }


}
